package net.wangxl;

import net.wangxl.dao.data1.BigDataMapper;
import net.wangxl.domain.BigData;
import org.assertj.core.internal.bytebuddy.utility.RandomString;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.quartz.QuartzProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringbootApplicationTestDemo {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private BigDataMapper bigDataMapper;

    @Test
    public void contextLoads() throws InterruptedException {

        System.out.println(new Date());
        ExecutorService pool = Executors.newFixedThreadPool(4);
        CountDownLatch cdl = new CountDownLatch(4);
        for(int i=0;i<4;i++){
            pool.submit(()->{
                for(int j=0;j<2500;j++){
                    RandomString randomString = new RandomString();
                    Random random = new Random();
                    BigData ddd = new BigData();
                    ddd.setName(randomString.nextString());
                    ddd.setAge(random.nextInt(100));
                    ddd.setIdNumber(randomString.nextString());
                    ddd.setNote(randomString.nextString());
                    bigDataMapper.insertSelective(ddd);
                }
                cdl.countDown();
            });
        }
        cdl.await();
        System.out.println(new Date());
    }

}

